package PAT;

import java.util.Scanner;

public class PAT1007 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = scanner.nextInt();
        }
        int ans = 1 << 31;
        int temp = 0;
        int l = 0, r = n - 1;
        int ln = 0, rn = n - 1;
        int index = 0;
        for (int value : values) {
            if (temp <= 0) {
                temp = value;
                l = index;
            } else {
                temp += value;
                r = index;
                if(ans < temp){
                    ans = temp;
                    ln = l;
                    rn  =r ;
                }
            }
            index++;
        }
        System.out.printf("%d %d %d\n",ans,ln,rn);

    }
}
